package com.baseLearn.learn.designPatterns.proxy.jdkDynamicProxy;

/**
 * 1.2代理模式-动态代理
 */
public class MainTest {

    public static void main(String[] args) {
        //流程:
        //利用JDK反射代理

        //优点：
        //代理对象动态生成,不需要实现接口,但是目标对象一定要实现接口(否则不能用动态代理)

        //目标对象类
        System.out.println(John.class);
        System.out.println(new John().getClass());

        //生成动态代理对象
        Person proxyInstant = (Person) new LawyerFactory().help(new John()).getProxyInstant();
        proxyInstant.talk();

        System.out.println("=LawyerFactory2=");
        //2.LawyerFactory2
        Person personLawyer = (Person) new LawyerFactory2().help(new John()).getInstance();
        personLawyer.talk();
    }
}
